<%@page contentType="text/html;charset=UTF-8" %>

<jsp:useBean id="regist" scope="session" class="BeanRegistration.Registration"/>
<jsp:useBean id="CMPBean" scope="application" class="BeanRegistration.CMPBean">
<%
   CMPBean.conect("indi/RegistrationBean");
        %>
    </jsp:useBean>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
    
        <title>JSP Page</title>
    </head>
    <body>
    
   
  <h1>JSP Page</h1>          
  <% request.setCharacterEncoding("UTF-8");
     response.setCharacterEncoding("UTF-8");
  %>
 
  <jsp:setProperty name="regist" property="login" param="Login"/>
  <jsp:setProperty name="regist" property="password" param="Password"/>
  <jsp:setProperty name="regist" property="lastname" param="Lastname"/>
  <jsp:setProperty name="regist" property="firstname" param="Firstname"/>
  <jsp:setProperty name="regist" property="email" param="email"/>
  <jsp:setProperty name="regist" property="user" param="User"/>
  <h5><%=  regist.getPassword() %></h5> 
  <h5><%=  regist.getLogin() %></h5> 
        <%
           if(regist.getLastname()!= null){
               if(regist.getFirstname()!=null){
                   if(regist.getemail()!= null){
                       int user;
                       if(regist.getUser().equals("SuperUser")){
                           user=1;
                       }else{
                           user=0;
                       }
                       CMPBean.create(regist.getPassword(),regist.getLogin(),user,regist.getLastname(),regist.getFirstname(),regist.getemail());
                   %>
                   <%if(request.getParameter("next")!=null ){ %>
                   <%if(regist.getUser().equals("SuperUser")){%><jsp:forward page="superUser.jsp" /> <% }%>
                   <jsp:forward page="viewUser.jsp"/>
                   <%}%>
                   
                   
                   <h5>пользователь добавлен</h5>
                   <%
                      }
               }
           }else{
               
        %>
  
      <form method="POST" action="regist.jsp">
        <table border="1" >
            <thead>
                <tr>
                    <td>Login*</td>
                    <td><input type="text" name="Login" value="<%=  request.getParameter("login") %>" /></td>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Password*</td>
                    <td><input type="password" name="Password" value="<%=  request.getParameter("password")  %>" /></td>
                </tr>
                <tr>
                    <td>User*</td>
                    <td><select name="User" >
                            <option>User</option>
                            <option>SuperUser</option>
                         </select>
                </td>
                </tr>
                <tr>
                    <td>Lastname*</td>
                    <td><input type="text" name="Lastname" value="" /></td>
                </tr>
                <tr>
                    <td>Firstname*</td>
                    <td><input type="text" name="Firstname" value="" /></td>
                </tr>
                <tr>
                    <td>e-mail*</td>
                    <td><input type="text" name="email" value="" /></td>
                </tr>
                <tr>
                    <td><input type="submit" value="registration"> </td>
                    <td align="center"><input name="next"  type="submit" value="next |>" /> </td>
               </tr>         
                <tr>
                    <td><td> <%= "--"+request.getCharacterEncoding() %></td></td>
                </tr>
            </tbody>
        </table>
        </form>
        <%
        }
        %>
  
    </body>
</html>
